<?php
$router = $di->getRouter();
$router->add('/', array(
    'controller' => 'index',
    'action'     => 'index',
));
$router->add('/logout', array(
    'controller' => 'index',
    'action'     => 'logout',
));
$router->add('/u/profile', array(
    'controller' => 'user',
    'action'     => 'profile',
));
$router->notFound(array(
    "controller" => "index",
    "action"     => "error404",
));
$router->add('/readme.html', array(
    'controller' => 'index',
    'action'     => 'readme',
));
//将插件的action写入路由
$file = file_get_contents(BASE_PATH . '/_app/config.json');
$file = json_decode($file, true);
foreach ($file as $key => $value) {
    if ($value['resource']) {
        foreach ($value['resource'] as $k => $v) {

            $router->add(
                '/{siteid:[\w]+}/' . $key . '/' . $v,
                [
                    'controller' => $key,
                    'action'     => $v,
                ]
            );
        }
    }
}
$router->handle();
